Source for file SC_Customer.php
Documentation is available at SC_Customer.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
function SC_Customer( $conn = '', $email = '', $pass = '' ) {
/* startSessionから移動 2005/11/04 中川 */
SC_Utils_Ex::sfDomainSessionStart();
$DB_class_name = "SC_DbConn";
if ( is_a($conn, $DB_class_name)){
// $connが$DB_class_nameのインスタンスである
//$DB_class_nameのインスタンスを作成する
// $this->setCustomerDataFromEmail( $email );
echo "DB接続オブジェクトの生成に失敗しています";
$sql_mobile = $mobile ? ' OR email_mobile = ?' : '';
$arrValues = array($email);
$sql = "SELECT * FROM dtb_customer WHERE (email = ?" . $sql_mobile . ") AND del_flg = 0 AND status = 2";
$result = $this->conn->getAll($sql, $arrValues);
// パスワードが合っていれば顧客情報をcustomer_dataにセットしてtrueを返す
if ( sha1($pass . ":" . AUTH_MAGIC) == $data['password'] ){
* 携帯端末IDが一致する会員が存在するかどうかをチェックする。
* @return boolean 該当する会員が存在する場合は true、それ以外の場合
if($_SESSION['mobile']['phone_id'] == "" && strlen($_SESSION['mobile']['phone_id']) == 0)
if (!isset ($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
// 携帯端末IDが一致し、本登録された会員を検索する。
$sql = 'SELECT count(*) FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2';
$result = $this->conn->getOne($sql, array($_SESSION['mobile']['phone_id']));
* 携帯端末IDを使用して会員を検索し、パスワードの照合を行う。
* パスワードが合っている場合は顧客情報を取得する。
* @param string $pass パスワード
* @return boolean 該当する会員が存在し、パスワードが合っている場合は true、
if($_SESSION['mobile']['phone_id'] == "" && strlen($_SESSION['mobile']['phone_id']) == 0)
if (!isset ($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
// 携帯端末IDが一致し、本登録された会員を検索する。
$sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2';
@list ($data) = $this->conn->getAll($sql, array($_SESSION['mobile']['phone_id']));
// パスワードが合っている場合は、顧客情報をcustomer_dataに格納してtrueを返す。
if (sha1($pass . ':' . AUTH_MAGIC) == @$data['password']) {
if (!isset ($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
if ($this->customer_data['mobile_phone_id'] == $_SESSION['mobile']['phone_id']) {
$sqlval = array('mobile_phone_id' => $_SESSION['mobile']['phone_id']);
$where = 'customer_id = ? AND del_flg = 0 AND status = 2';
$objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id']));
$this->customer_data['mobile_phone_id'] = $_SESSION['mobile']['phone_id'];
* email から email_mobile へ携帯のメールアドレスをコピーする。
$objMobile = new SC_Helper_Mobile_Ex();
// すでに email_mobile に値が入っている場合は何もしない。
// email が携帯のメールアドレスではない場合は何もしない。
if (!$objMobile->gfIsMobileMailAddress($this->customer_data['email'])) {
// email から email_mobile へコピーする。
$sqlval = array('email_mobile' => $this->customer_data['email']);
$where = 'customer_id = ? AND del_flg = 0 AND status = 2';
$objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id']));
$sql = "SELECT * FROM dtb_customer WHERE (email = ? OR email_mobile = ?) AND del_flg = 0 AND status = 2";
$result = $this->conn->getAll($sql, array($email, $email));
$data = isset ($result[0]) ? $result[0] : "";
$sql = "SELECT * FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
$customer_id = $this->getValue('customer_id');
$arrRet = $this->conn->getAll($sql, array($customer_id));
// ログイン情報をセッションに登録し、ログに書き込む
SC_Utils_Ex::sfDomainSessionStart();
GC_Utils_Ex::gfPrintLog("access : user=". $this->customer_data['customer_id'] . "\t". "ip=". $this->getRemoteHost(), CUSTOMER_LOG_PATH );
// ログアウト $_SESSION['customer']を解放し、ログに書き込む
// $_SESSION['customer']の解放
unset ($_SESSION['customer']);
$objSiteSess->unsetUniqId();
$objCartSess->delAllProducts();
GC_Utils_Ex::gfPrintLog("logout : user=". $this->customer_data['customer_id'] . "\t". "ip=". $this->getRemoteHost(), CUSTOMER_LOG_PATH );
// ログイン時のメールアドレスとDBのメールアドレスが一致している場合
if(isset ($_SESSION['customer']['customer_id'])
&& SC_Utils_Ex::sfIsInt($_SESSION['customer']['customer_id'])) {
$email = $objQuery->get("dtb_customer", "email", "customer_id = ?", array($_SESSION['customer']['customer_id']));
if($email == $_SESSION['customer']['email']) {
// モバイルサイトの場合は携帯のメールアドレスが登録されていることもチェックする。
// ただし $dont_check_email_mobile が true の場合はチェックしない。
if (defined('MOBILE_SITE') && !$dont_check_email_mobile) {
$email_mobile = $objQuery->get("dtb_customer", "email_mobile", "customer_id = ?", array($_SESSION['customer']['customer_id']));
return isset ($email_mobile);
return isset ($_SESSION['customer'][$keyname]) ? $_SESSION['customer'][$keyname] : "";
$_SESSION['customer'][$keyname] = $val;
return isset ($_SESSION['customer'][$keyname]);
if (isset ($_SESSION['customer']['birth'])) {
$arrRet = split("[- :/]", $_SESSION['customer']['birth']);
$birth_month = intval($arrRet[1]);
if($birth_month == $now_month) {
* $_SERVER['REMOTE_HOST'] または $_SERVER['REMOTE_ADDR'] を返す.
* $_SERVER['REMOTE_HOST'] が取得できない場合は $_SERVER['REMOTE_ADDR']
* @return string $_SERVER['REMOTE_HOST'] 又は $_SERVER['REMOTE_ADDR']の文字列
if (!empty($_SERVER['REMOTE_HOST'])) {
return $_SERVER['REMOTE_HOST'];
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
Documentation generated on Fri, 24 Feb 2012 14:00:01 +0900 by Seasoft
|